Add __all__ exports and improve backoff retry configuration#1993
Add __all__ exports and improve backoff retry configuration#1993
Conversation
Define an explicit public API surface by re-exporting the most commonly used classes (client, models, auth credentials, exceptions) from the top-level pyoverkiz package.
Cap total retry duration with max_time on each decorator and add full_jitter to avoid thundering herd on concurrent retries.
There was a problem hiding this comment.
Pull request overview
This PR aims to simplify the library’s public API by re-exporting commonly used symbols from pyoverkiz/__init__.py, and to make retry behavior more resilient by capping total retry duration and adding jitter to backoff decorators.
Changes:
- Add
max_timeandjitter=backoff.full_jitterto all reusablebackoff.on_exceptiondecorators inpyoverkiz/client.py. - Add package-root re-exports and an explicit
__all__inpyoverkiz/__init__.py.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pyoverkiz/client.py |
Adds max_time and jitter to backoff decorators to cap retry duration and reduce thundering-herd retries. |
pyoverkiz/__init__.py |
Introduces top-level re-exports and __all__ to define a cleaner public import surface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from pyoverkiz.auth import ( | ||
| Credentials, | ||
| LocalTokenCredentials, | ||
| RexelOAuthCodeCredentials, | ||
| TokenCredentials, | ||
| UsernamePasswordCredentials, | ||
| ) |
There was a problem hiding this comment.
Importing credential classes from pyoverkiz.auth pulls in pyoverkiz.auth.factory and pyoverkiz.auth.strategies (via pyoverkiz/auth/__init__.py), which imports heavy optional runtime deps like boto3 at module import time. That makes a plain import pyoverkiz significantly heavier than necessary for users who only need models/exceptions. Prefer importing these symbols directly from pyoverkiz.auth.credentials (or use a lazy re-export via __getattr__) to keep top-level imports lightweight.
| from pyoverkiz.client import OverkizClient | ||
| from pyoverkiz.exceptions import ( |
There was a problem hiding this comment.
Re-exporting OverkizClient from the package root forces pyoverkiz/client.py to be imported on every import pyoverkiz. That module creates SSL_CONTEXT_LOCAL_API at import time, which loads the bundled CA cert from disk (blocking I/O). Consider making the client import lazy (PEP 562 __getattr__) and/or moving SSL context creation behind a lazy getter so importing the package doesn’t perform file I/O.
| __all__ = [ | ||
| "Action", | ||
| "ActionGroup", | ||
| "BadCredentialsException", | ||
| "BaseOverkizException", | ||
| "Command", | ||
| "Credentials", | ||
| "Device", | ||
| "Event", | ||
| "Execution", | ||
| "Gateway", | ||
| "LocalTokenCredentials", | ||
| "MaintenanceException", | ||
| "NotAuthenticatedException", | ||
| "OverkizClient", | ||
| "OverkizException", | ||
| "Place", | ||
| "RexelOAuthCodeCredentials", | ||
| "ServerConfig", | ||
| "Setup", | ||
| "State", | ||
| "TokenCredentials", | ||
| "TooManyRequestsException", | ||
| "UsernamePasswordCredentials", | ||
| ] |
There was a problem hiding this comment.
New top-level re-exports/__all__ are part of the public API, but there’s no test asserting these names are importable from pyoverkiz (e.g., from pyoverkiz import OverkizClient, Credentials, Action). Adding a small importability test would prevent accidental breakage and ensure __all__ stays in sync with actual exports.
Summary
__all__and re-exports to package__init__.pyfor cleaner public APImax_timeandjitterto all backoff retry decorators for more resilient retry behaviorTest plan
pyoverkiz